
<!doctype html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><simple-form-modal-component> ⌲ Examples ⌲ Basic</title>
    <link rel="stylesheet" href="../docs.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
    <link href="../prism-okaidia.css" rel="stylesheet" />
    <script type="module" src="../simple-form-modal-component.bundled.js"></script>
  </head>
  <body>
    
<header>
  <h1>&lt;simple-form-modal-component></h1>
  <h2>A simple form web component just for me.</h2>
</header>
    
<nav>
  <a href="../">Home</a>
  <a href="">Examples</a>
  <a href="../api/">API</a>
  <a href="../install/">Install</a>
</nav>
    <div id="main-wrapper">
      <main>
        
    <h1>Example: Basic</h1>
    <section class="examples">
      <nav class="collection">
        <ul>
          
                  <li class=selected>
                    <a href="">A basic example</a>
                  </li>
                
                  <li class=>
                    <a href="name-property/">Setting the name property</a>
                  </li>
                
        </ul>
      </nav>
      <div>
        <script async src="https://unpkg.com/browse/@webcomponents/webcomponentsjs@2.4.3/webcomponents-bundle.js"></script>
<script async type="module" src="http://unpkg.com/apress-simple-form-modal-component@1.0.3/dist/index.js"></script>
<p><button id="myBtn">Open Modal</button>
<simple-form-modal-component></simple-form-modal-component></p>
<script>
  const myBtn = document.getElementById('myBtn');
  const formModal = document.querySelector('simple-form-modal-component');
  myBtn.addEventListener('click', function() {
    formModal.open = !formModal.open;
  });
  formModal.addEventListener('addEvent', function(e) {
    console.log("Event:", e.detail);
  });
</script>
<h3>HTML</h3>
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>myBtn<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Open Modal<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>simple-form-modal-component</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>simple-form-modal-component</span><span class="token punctuation">></span></span></code></pre>
<pre class="language-js"><code class="language-js">  <span class="token keyword">const</span> myBtn <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">getElementById</span><span class="token punctuation">(</span><span class="token string">'myBtn'</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br>  <span class="token keyword">const</span> formModal <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">querySelector</span><span class="token punctuation">(</span><span class="token string">'simple-form-modal-component'</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br>  myBtn<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">'click'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br>    formModal<span class="token punctuation">.</span>open <span class="token operator">=</span> <span class="token operator">!</span>formModal<span class="token punctuation">.</span>open<span class="token punctuation">;</span><br>  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span><br>  formModal<span class="token punctuation">.</span><span class="token function">addEventListener</span><span class="token punctuation">(</span><span class="token string">'addEvent'</span><span class="token punctuation">,</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><br>    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">"Event:"</span><span class="token punctuation">,</span> e<span class="token punctuation">.</span>detail<span class="token punctuation">)</span><span class="token punctuation">;</span><br>  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>

      </div>
    </section>
  
      </main>
    </div>
    
<footer>
  <p>
    Made with Love.
  </p>
</footer>
  </body>
</html>